665A - Buses Between Cities - CodeForces Solution


implementation *1600

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#define int long long 
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define pre(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
const int N=2e5+10,INF=0x3f3f3f3f,mod=1e9+7;

inline int read() {
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')f=((ch=='-')?-1:f),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}


void solve(){
	int a=read(),ta=read();
	int b=read(),tb=read();
	int h,m;
	scanf("%lld:%lld",&h,&m);
	int t1=h*60+m,t2=t1+ta;
	//cout<<t1-tb<<" "<<t2<<endl;
	int bt=5*60;
	int ans=0;
	for(int i=bt;i<=23*60+59;i+=b){
		//cout<<i<<endl;
		if(t1-tb<i&&i<t2)ans++;
	}
	cout<<ans;
	
}

signed main(){ 
	int T=1;
	//T=read();
	while(T--)solve();
    return 0;
}
/*
10 30
10 35
05:35 


*/

 					    		 	 		 	   		 	 				


Comments

Submit
0 Comments
More Questions

1738C - Even Number Addicts
1064B - Equations of Mathematical Magic
384A - Coder
1738B - Prefix Sum Addicts
1352D - Alice Bob and Candies
1316D - Nash Matrix
1548B - Integers Have Friends
348A - Mafia
315B - Sereja and Array
204A - Little Elephant and Interval
385B - Bear and Strings
114C - Grammar Lessons
1427A - Avoiding Zero
583A - Asphalting Roads
1358B - Maria Breaks the Self-isolation
828A - Restaurant Tables
1735A - Working Week
1735D - Meta-set
1735B - Tea with Tangerines
1735C - Phase Shift
1321C - Remove Adjacent
281B - Nearest Fraction
1043A - Elections
1598C - Delete Two Elements
1400C - Binary String Reconstruction
1734D - Slime Escape
1499A - Domino on Windowsill
991A - If at first you don't succeed
1196C - Robot Breakout
373A - Collecting Beats is Fun